import mockjs from 'mockjs'
import { MockHandler } from '../types'
import url from 'node:url'

export const listHandler: MockHandler = (req, res) => {
  const query = url.parse(req.url!, true).query
  const data = mockjs.mock({
    'list|20': [
      {
        'id|+1': 1,
        name: query.keyword,
        'age|18-60': 1,
        address: '@county(true)',
        email: '@email',
        url: '@url'
      }
    ]
  })
  res.end(JSON.stringify(data))
}
